﻿using System.Linq.Expressions;

namespace Basic.ScheduledTask.Abstract;

public interface IJobManager
{
    HashSet<string> LoadedJobIds { get; }

    void AddOnceJob(Expression<Func<Task>> expression);
    void AddOnceJob(Expression<Func<Task>> expression, DateTimeOffset time);
    void DelayJob(Expression<Func<Task>> expression, TimeSpan delayTime);

    bool AddRecurringJob(string jobId, Expression<Func<Task>> expression, string cron);
    bool AddRecurringJob<T>(string jobId, Func<T, Task> action, string cron) where T : class;

    void RemoveJob(string jobId);

    bool Contains(string jobId);

    #region IScheduledJob

    void AddOnceJob(IScheduledJob job);

    void AddOnceJob(IScheduledJob job, TimeSpan delayTime);

    void AddOnceJob(IScheduledJob job, DateTimeOffset time);

    bool AddRecurringJob(string jobId, IScheduledJob job, object[] paras = null);

    #endregion

}